﻿<!DOCTYPE HTML>
<html>
<head>
	@include('common.header')
	<title>Banner管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> Banner管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="datadel()" class="btn btn-danger"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
			<a class="btn btn-primary" href="javascript:;" onclick="layer_show('添加Banner','{{url('Banner/edit.html')}}',600,550)"><i class="Hui-iconfont">&#xe600;</i> 添加Banner</a>
		</span>
		<span class="r">共有数据：<strong>{{count($list)}}</strong> 条</span>
	</div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th width="80">ID</th>
					<th>标题</th>
					<th>img</th>
					<th>链接地址</th>
					<th>排序</th>
					<th>是否展示</th>
					<th>操作时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				@foreach($list as $v)
				<tr class="text-c">
					<td><input type="checkbox" value="{{$v['id']}}" name="ids"></td>
					<td>{{$v['id']}}</td>
					<td>{{$v['title']}}</td>
					<td>
						@if($v['img'])
							<img src="{{$v['img']}}" width="50" height="50">
						@endif
					</td>
					<td>{{$v['url']}}</td>
					<td>{{$v['sort']}}</td>
					<td>
						@if($v['is_show'])
							展示
						@else
							不展示
						@endif
					</td>
					<td>{{$v['updated_at']}}</td>
					<td class="f-14 td-manage">
						<button class="ml-5 btn btn-success" onclick="layer_show('编辑','{{url('Banner/edit.html')}}?id={{$v['id']}}',600,550)" title="编辑">编辑</button>
						<button class="ml-5 btn btn-danger" onclick="del(this,{{$v['id']}});" title="删除">删除</button>
					</td>
				</tr>
				@endforeach
			</tbody>
		</table>
	</div>
</div>
@include('common.footer')

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="{{asset('hui-admin/lib/My97DatePicker/4.8/WdatePicker.js')}}"></script>
<script type="text/javascript" src="{{asset('hui-admin/lib/datatables/1.10.0/jquery.dataTables.min.js')}}"></script>
<script type="text/javascript" src="{{asset('hui-admin/lib/laypage/1.2/laypage.js')}}"></script>
<script type="text/javascript">

    function del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '/Banner/del',
				data: {'id':id},
                dataType: 'json',
                success: function(data){
                    if(data.code == 1){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        layer.msg(data.msg,function () {});
					}
                }
            });
        });
    }

    function datadel(){
        var ids = [];
        $("input[name=ids]:checked").each(function(i){
            ids[i] = $(this).val();
        });
        var id = ids.join(',');
        if(isNull(id)){
            layer.msg('请选择批量删除的品牌',function () {});
		}else{
            layer.confirm('确认要删除这些品牌吗？',function(index){
				$.ajax({
					type: 'POST',
					url: '/Banner/del',
					data: {'id':id},
					dataType: 'json',
					success: function(data){
						if(data.code == 1){
							layer.msg('已删除!',{icon:1,time:1000});
							refresh();
						}else{
							layer.msg(data.msg,function () {});
						}
					}
				});
            });
		}
	}

</script>
</body>
</html>